package classDemo;

/**
 * Created by AJie on 2019/7/26
 * Function : 正常构造 对象，
 * 所有属性块 顺序
 * 1、父 static
 *      static {}
 * 2、子 static
 *      static {}
 * 3、父 {}
 *      instance
 * 4、子 {}
 *      instanc
 *
 * ParentSingleton44 static field
 * ParentSingleton44 static block
 * Singleton4 static field
 * Singleton4 static block
 * ParentSingleton44  block ！！！
 * ParentSingleton44 new instance
 * Singleton4  block ！！！
 * Singleton4 new instance
 */
public class ClassLoad4_Parent {
    public static void main(String args[]){
        Singleton4 singleton = new Singleton4();
    }
}
class Singleton4 extends ParentSingleton44 {
    private static int mField= getNum();

    private static int getNum() {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Singleton4 static field");
        return 0;
    }
    public Singleton4() {
        System.out.println("Singleton4 new instance");
    }

    static {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Singleton4 static block");
    }

    {
        System.out.println("Singleton4  block ！！！ ");
    }

}

class ParentSingleton44{
    private static int mField= getNum();

    private static int getNum() {
        System.out.println("ParentSingleton44 static field");
        return 0;
    }

    public ParentSingleton44(){
        System.out.println("ParentSingleton44 new instance");
    }

    static {
        System.out.println("ParentSingleton44 static block");
    }

    {
        System.out.println("ParentSingleton44  block ！！！ ");
    }

}
